<?php

namespace App\Http\Controllers;

use App\formModel;
use App\InfoModel;
use Illuminate\Http\Request;

class formController extends Controller
{
    public function korux()
    {
        $list = formModel::get();
        return view('formtable', compact('list'));
    }

    public function form()
    {

        return view("form");
    }


    public function add(Request $request)
    {
        $id = $request->input('id');
//        $uqur = formModel::where('id',$id)->get()[0];
        $uqur = formModel::where('id', $id)->first();
        return view("form", compact('uqur'));
    }

    public function tianjia(Request $request)
    {
        $data = $request->input();
//        $data = $request->except("_token");
        unset($data['_token']);
        $data['hobby'] = implode("*", $data['hobby']);
        $ok = formModel::create($data);
        if ($ok) {
            return "信息添加成功！<br> <a href='korux'> 返回首页 </a>";
        } else {
            return "信息添加失败！";
        }
    }
}
